/* Copyright (c) 2006, 2009, Carl Burch. License information is located in the
 * com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */
 
package com.cburch.draw.actions;

import com.cburch.draw.canvas.CanvasModel;
import com.cburch.draw.canvas.CanvasObject;
import com.cburch.logisim.util.Strings;

public class ModelDeleteHandleAction extends ModelAction {
    private CanvasObject handleObject;
    private int handleIndex;
    
    public ModelDeleteHandleAction(CanvasModel model, CanvasObject shape, int index) {
        super(model);
        handleObject = shape;
        handleIndex = index;
    }

    public String getName() {
        return Strings.get("actionDeleteHandle", Strings.drawSource);
    }
    
    void doSub(CanvasModel model) {
        model.deleteHandle(handleObject, handleIndex);
    }
    
    void undoSub(CanvasModel model) {
        if(handleObject.canInsertHandle(handleIndex)) {
            model.insertHandle(handleObject, handleIndex);
        }
    }
}
